  
  * APPENDIX C 
  
  * Appendix C2 - Distribution of variables 
  
  * NOTE TO USER: To replicate dofile, please create one folder named "distribution" and another named "correlation" and place these two folders in the folder named "data"
  
  cd "${data}"
  use "dataset.dta", clear
	

 drop if country_year_==.
 
 
 *first dot plots for each item
 
 gen selfplacement_voter = selfplacement if voted==1
 gen selfplacement_nonvoter = selfplacement if voted==0

 gen redistribution_voter = redistribution if voted==1
 gen redistribution_nonvoter = redistribution if voted==0

 gen regulation_voter = regulation if voted==1
 gen regulation_nonvoter = regulation if voted==0
 
 gen spending_voter = spending if voted==1
 gen spending_nonvoter = spending if voted==0
  
 gen environment_voter = environment if voted==1
 gen environment_nonvoter = environment if voted==0
 
  gen immigration_voter = immigration if voted==1
 gen immigration_nonvoter = immigration if voted==0
 
  gen samesexmarriage_voter = samesexmarriage if voted==1
 gen samesexmarriage_nonvoter = samesexmarriage if voted==0
 
  gen laworder_voter = laworder if voted==1
 gen laworder_nonvoter = laworder if voted==0
 
  gen euintegration_voter = euintegration if voted==1
 gen euintegration_nonvoter = euintegration if voted==0


 dotplot selfplacement_voter selfplacement_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
graph save "${data}/distribution/selfplacement_votersnonvotersdp.gph", replace 
 
  dotplot redistribution_voter redistribution_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
 graph save "${data}/distribution/redistribution_votersnonvotersdp.gph", replace 

   dotplot regulation_voter regulation_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
 graph save "${data}/distribution/regulation_votersnonvotersdp.gph", replace 

   dotplot spending_voter spending_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
 graph save "${data}/distribution/spending_votersnonvotersdp.gph", replace 

    dotplot environment_voter environment_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
 graph save "${data}/distribution/environment_votersnonvotersdp.gph", replace 

     dotplot immigration_voter immigration_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
 graph save "${data}/distribution/immigration_votersnonvotersdp.gph", replace 

     dotplot samesexmarriage_voter samesexmarriage_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
graph save "${data}/distribution/samesexmarriage_votersnonvotersdp.gph", replace 

	 dotplot laworder_voter laworder_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
	graph save "${data}/distribution/laworder_votersnonvotersdp.gph", replace 

 	 dotplot euintegration_voter euintegration_nonvoter, mcolor(gs6%50) msize(0.3pt) msymbol(circle_hollow) jitter(6) xlabel(1"voters" 2"non-voters", labsize(medium) angle(horizontal)) ylabel() ytitle("" , size(small))
		  graph save "${data}/distribution/eu_votersnonvotersdp.gph", replace 

	
	
	
	
	* boxplot for each item 
	
graph box selfplacement_voter selfplacement_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/selfplacement_votersnonvotersbp.gph", replace 

graph box redistribution_voter redistribution_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/redistribution_votersnonvotersbp.gph", replace 

graph box regulation_voter regulation_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/regulation_votersnonvotersbp.gph", replace 

graph box spending_voter spending_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/spending_votersnonvotersbp.gph", replace 

graph box environment_voter environment_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/environment_votersnonvotersbp.gph", replace 

graph box immigration_voter immigration_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/immigration_votersnonvotersbp.gph", replace 

graph box samesexmarriage_voter samesexmarriage_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/samesexmarriage_votersnonvotersbp.gph", replace 

graph box laworder_voter laworder_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/laworder_votersnonvotersbp.gph", replace 

graph box euintegration_voter euintegration_nonvoter, box(1,color(gs5%50)) medtype(line) marker(1, msize(tiny) mcolor(gs5%50)) box(2,color(gs5%50)) marker(2, msize(tiny) mcolor(gs5%50)) ylabel(, nogrid) legend(off)
 graph save "${data}/distribution/eu_votersnonvotersbp.gph", replace 

 
 
cd "${data}/distribution"	  
	graph combine selfplacement_votersnonvotersdp.gph selfplacement_votersnonvotersbp.gph, l1("left-right")
	graph save "${figures}/selfplacement_merged.gph", replace 
	graph export "${figures}/selfplacement_merged.png", as(png) replace
	
	graph combine redistribution_votersnonvotersdp.gph redistribution_votersnonvotersbp.gph, l1("redistribution")
	graph save "${figures}/redistribution_merged.gph", replace 
	graph export "${figures}/redistribution_merged.png", as(png) replace
		
	graph combine regulation_votersnonvotersdp.gph regulation_votersnonvotersbp.gph, l1("state control of the economy")
	graph save "${figures}/regulation_merged.gph", replace 
	graph export "${figures}/regulation_merged.png", as(png) replace

 	graph combine spending_votersnonvotersdp.gph spending_votersnonvotersbp.gph, l1("spending")
	graph save "${figures}/spending_merged.gph", replace 
	graph export "${figures}/spending_merged.png", as(png) replace

 	graph combine environment_votersnonvotersdp.gph environment_votersnonvotersbp.gph, l1("environment")
 	graph save "${figures}/environment_merged.gph", replace 
	graph export "${figures}/environment_merged.png", as(png) replace

	graph combine immigration_votersnonvotersdp.gph immigration_votersnonvotersbp.gph, l1("immigration")
 	graph save "${figures}/immigration_merged.gph", replace 
	graph export "${figures}/immigration_merged.png", as(png) replace

	graph combine samesexmarriage_votersnonvotersdp.gph samesexmarriage_votersnonvotersbp.gph, l1("same-sex marriage")
 	graph save "${figures}/samesexmarriage_merged.gph", replace 
	graph export "${figures}/samesexmarriage_merged.png", as(png) replace

		
 	graph combine laworder_votersnonvotersdp.gph laworder_votersnonvotersbp.gph, l1("civil liberties")
	graph save "${figures}/laworder_merged.gph", replace 
	graph export "${figures}/laworder_merged.png", as(png) replace

 	graph combine eu_votersnonvotersdp.gph eu_votersnonvotersbp.gph, l1("European integration")
 	graph save "${figures}/eu_merged.gph", replace 
	graph export "${figures}/eu_merged.png", as(png) replace

 

	
  * Appendix C3 - Correlation between items at the survey level
  
  cd "${data}"
  use "dataset.dta", clear
	
	
bysort country_year_: egen lr_redist = corr(selfplacement redistribution)
bysort country_year_: egen lr_regulation = corr(selfplacement regulation)
bysort country_year_: egen lr_spending = corr(selfplacement spending)
bysort country_year_: egen lr_environment = corr(selfplacement environment)
bysort country_year_: egen lr_immigration = corr(selfplacement immigration)
bysort country_year_: egen lr_samesexmarriage = corr(selfplacement samesexmarriage)
bysort country_year_: egen lr_laworder = corr(selfplacement laworder)
bysort country_year_: egen lr_eu = corr(selfplacement euintegration)

bysort country_year_: egen redist_regulation = corr(redistribution regulation)
bysort country_year_: egen redist_spending = corr(redistribution spending)
bysort country_year_: egen redist_environment = corr(redistribution environment)
bysort country_year_: egen redist_immigration = corr(redistribution immigration)
bysort country_year_: egen redist_samesexmarriage = corr(redistribution samesexmarriage)
bysort country_year_: egen redist_laworder = corr(redistribution laworder)
bysort country_year_: egen redist_eu = corr(redistribution euintegration)


bysort country_year_: egen regulation_spending = corr(regulation spending)
bysort country_year_: egen regulation_environment = corr(regulation environment)
bysort country_year_: egen regulation_immigration = corr(regulation immigration)
bysort country_year_: egen regulation_samesexmarriage = corr(regulation samesexmarriage)
bysort country_year_: egen regulation_laworder = corr(regulation laworder)
bysort country_year_: egen regulation_eu = corr(regulation euintegration)

bysort country_year_: egen spending_environment = corr(spending environment)
bysort country_year_: egen spending_immigration = corr(spending immigration)
bysort country_year_: egen spending_samesexmarriage = corr(spending samesexmarriage)
bysort country_year_: egen spending_laworder = corr(spending laworder)
bysort country_year_: egen spending_eu = corr(spending euintegration)

bysort country_year_: egen environment_immigration = corr(environment immigration)
bysort country_year_: egen environment_samesexmarriage = corr(environment samesexmarriage)
bysort country_year_: egen environment_laworder = corr(environment laworder)
bysort country_year_: egen environment_eu = corr(environment euintegration)

bysort country_year_: egen immigration_samesexmarriage = corr(immigration samesexmarriage)
bysort country_year_: egen immigration_laworder = corr(immigration laworder)
bysort country_year_: egen immigration_eu = corr(immigration euintegration)


bysort country_year_: egen samesexmarriage_laworder = corr(samesexmarriage laworder)
bysort country_year_: egen samesexmarriage_eu = corr(samesexmarriage euintegration)


bysort country_year_: egen laworder_eu = corr(laworder euintegration)


keep country_year_ lr_redist lr_regulation lr_spending lr_environment lr_immigration lr_samesexmarriage lr_laworder lr_eu redist_regulation redist_spending redist_environment redist_immigration redist_samesexmarriage redist_laworder redist_eu regulation_spending regulation_environment regulation_immigration regulation_samesexmarriage regulation_laworder regulation_eu spending_environment spending_immigration spending_samesexmarriage spending_laworder spending_eu environment_immigration environment_samesexmarriage environment_laworder environment_eu immigration_samesexmarriage immigration_laworder immigration_eu samesexmarriage_laworder samesexmarriage_eu laworder_eu
 

duplicates drop
decode country_year_, generate(country_year)

collapse (firstnm) country_year lr_redist lr_regulation lr_spending lr_environment lr_immigration lr_samesexmarriage lr_laworder lr_eu redist_regulation redist_spending redist_environment redist_immigration redist_samesexmarriage redist_laworder redist_eu regulation_spending regulation_environment regulation_immigration regulation_samesexmarriage regulation_laworder regulation_eu spending_environment spending_immigration spending_samesexmarriage spending_laworder spending_eu environment_immigration environment_samesexmarriage environment_laworder environment_eu immigration_samesexmarriage immigration_laworder immigration_eu samesexmarriage_laworder samesexmarriage_eu laworder_eu, by(country_year_)


cd "${data}/correlation" 
save "correlation.dta", replace 


use"correlation.dta", clear 


label variable lr_redist "LR - redistribution"
label variable lr_regulation "LR - regulation"
label variable lr_spending "LR - spending"
label variable lr_environment "LR - environment"
label variable lr_immigration "LR - immigration"
label variable lr_samesexmarriage "LR - samesexmarriage"
label variable lr_laworder "LR - civil liberties"
label variable lr_eu "LR - EU"

label variable redist_regulation "redistribution - regulation"
label variable redist_spending "redistribution - spending"
label variable redist_environment "redistribution - environment"
label variable redist_immigration "redistribution - immigration"
label variable redist_samesexmarriage "redistribution - samesexmarriage"
label variable redist_laworder "redistribution - civil liberties"
label variable redist_eu "redistribution - EU"

label variable regulation_spending "regulation - spending"
label variable regulation_environment "regulation - environment"
label variable regulation_immigration "regulation - immigration"
label variable regulation_samesexmarriage "regulation - samesexmarriage"
label variable regulation_laworder "regulation - laworder"
label variable regulation_eu "regulation - EU"

label variable spending_environment "spending - environment"
label variable spending_immigration "spending - immigration"
label variable spending_samesexmarriage "spending - samesexmarriage"
label variable spending_laworder "spending - laworder"
label variable spending_eu "spending - EU"

label variable environment_immigration "environment - immigration"
label variable environment_samesexmarriage "environment - samesexmarriage"
label variable environment_laworder "environment - laworder"
label variable environment_eu "environment - EU"

label variable immigration_samesexmarriage "immigration - same-sexmarriage"
label variable immigration_laworder "immigration - civil liberties"
label variable immigration_eu "immigration - EU"

label variable samesexmarriage_laworder "same-sexmarriage - civil liberties"
label variable samesexmarriage_eu "same-sexmarriage - EU"

label variable laworder_eu "civil liberties - EU"

dotplot lr_redist lr_regulation lr_spending lr_environment lr_immigration lr_samesexmarriage lr_laworder lr_eu, mcolor(gs6%50) msize(1.25) msymbol(circle) jitter(4) xlabel(, labsize(vsmall) angle(vertical)) ylabel(-0.4(0.2)0.6) ytitle("correlation at survey level" , size(small))
graph save "${figures}/corr1.gph", replace 
graph export "${figures}/corr1.png", as(png) replace


dotplot redist_regulation redist_spending redist_environment redist_immigration redist_samesexmarriage redist_laworder redist_eu, mcolor(gs6%50) msize(1.25) msymbol(circle) jitter(4) xlabel(, labsize(vsmall) angle(vertical)) ylabel(-0.4(0.2)0.6) ytitle("correlation at survey level" , size(small))
graph save "${figures}/corr2.gph", replace 
graph export "${figures}/corr2.png", as(png) replace


dotplot regulation_spending regulation_environment regulation_immigration regulation_samesexmarriage regulation_laworder regulation_eu spending_environment spending_immigration, mcolor(gs6%50) msize(1.25) msymbol(circle) jitter(4) xlabel(, labsize(vsmall) angle(vertical)) ylabel(-0.4(0.2)0.6) ytitle("correlation at survey level" , size(small))
graph save "${figures}/corr3.gph", replace 
graph export "${figures}/corr3.png", as(png) replace


dotplot spending_samesexmarriage spending_laworder spending_eu environment_immigration environment_samesexmarriage environment_laworder environment_eu immigration_samesexmarriage , mcolor(gs6%50) msize(1.25) msymbol(circle) jitter(4) xlabel(, labsize(vsmall) angle(vertical)) ylabel(-0.4(0.2)0.6) ytitle("correlation at survey level" , size(small))
graph save "${figures}/corr4.gph", replace 
graph export "${figures}/corr4.png", as(png) replace

dotplot immigration_laworder immigration_eu samesexmarriage_laworder samesexmarriage_eu laworder_eu, mcolor(gs6%50) msize(1.25) msymbol(circle) jitter(4) xlabel(, labsize(vsmall) angle(vertical)) ylabel(-0.4(0.2)0.6) ytitle("correlation at survey level" , size(small))
graph save "${figures}/corr5.gph", replace 
graph export "${figures}/corr5.png", as(png) replace


	